<?php
include('../../inc/global.inc');
include("../islogin.php");
$url="friend.php";
$thepage=$_GET['page']?$_GET['page']:1;
$maxpage=20;
$check = intval($_GET['check']);
?>
<?php
//删除信息
if($_GET['delid']){
	mysql_query("delete from member_link where id=".$_GET['delid']);
	header("Location:friend.php?check=".$check."&page".$thepage);
}
?>
<HTML>
<HEAD>
<TITLE>Admin</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="../css/css.css" rel=stylesheet>
<script type='text/javascript' src="../js/islogin.js" charset="gb2312"></script>
</HEAD>
<BODY>
<center>
  <table width="95%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
	  <td height="25" bgcolor="#EEEEF9" style="padding-left:5px;">企业网站友情链接 &nbsp;&nbsp;<a href="friend.php?check=0">未审核</a>&nbsp;&nbsp;
<a href="friend.php?check=1">已审核</a>&nbsp;&nbsp;
<a href="javascript:history.go(-1)">返回</a></td>
    </tr>
  </table>

<table width="95%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
	<tr>
		<th colspan=6>
			<?php
		if($check==1)
		{
			echo '已审核的企业网站友情链接';
		}
		else
		{
			echo '未审核的企业网站友情链接';
		}
?>
		</th>
	</tr>
    <tr>
      <td width="6%" height="30" align="center" bgcolor="#8DA8CF">编号</td>
      <td width="12%" align="center" bgcolor="#8DA8CF">用户名</td>
      <td width="22%" align="center" bgcolor="#8DA8CF">链接名称</td>
      <td width="25%" align="center" bgcolor="#8DA8CF">链接地址</td>
      <td width="11%" align="center" bgcolor="#8DA8CF">添加时间</td>
      <td width="13%" align="center" bgcolor="#8DA8CF">管理</td>
    </tr>
<?php


$sql="select * from member_link where `check`=$check order by id desc limit ".($thepage-1)*$maxpage.",$maxpage";
$rs=mysql_query($sql);

$i=1;
while($row=mysql_fetch_array($rs)){
$color=($i%2)?"#FFFFFF":"#eeeeee";
?>
    <tr bgcolor=<?=$color?>>
      <td height="25" align="center"><?=$i?></td>
	  <td align="center">
			<?php 
			$sq = "select m_user from member where id=".$row[member_id];
			$member_rs = mysql_query($sq);
			$member_row = mysql_fetch_array($member_rs);
			echo $member_row['m_user'];
			?>
		</td>
	  <td align="center"><a href="<?=$row[link_url]?>" target="_blank"><?=$row[link_name]?></a></td>
	  <td align="center"><?=$row[link_url]?></td>
	  
	  <td align="center"><?=date('Y-m-d H:i',$row['create_time'])?></td>
	  <td align="center">
		<?php
		if($check==0)
		{
?>
		<a href="friend_check.php?id=<?=$row['id']?>&status=0">不通过</a> | 
		<a href="friend_check.php?id=<?=$row['id']?>&status=1">通过</a> |
		<a href="#" onClick="del_friendlink(<?=$row['id']?>)">删除</a>
<?php }else{
	if($row['status'] == 1)
	{
?>
审核通过
<?php }else
	{
?>
审核不通过
<?php }}?>
		
	</td>
    </tr>
<?php
$i++;}
//分页参数
$rs2=mysql_query("select count(*) from member_link where `check`=$check");
$totalrecord=mysql_result($rs2,0);
$totalpage=ceil($totalrecord/$maxpage);

?>

<tr><form method="get" action="<?=$url?>?check=<?=$check?>">
   <td height="25" colspan="7" align="center" bgcolor="#FFFFFF">
<?php if($thepage>1){?>
   <a href="<?=$url?>?check=<?=$check?>">第一页</a>&nbsp;<a href="<?=$url?>?page=<?=$thepage-1?>&check=<?=$check?>">上一页</a>&nbsp;
<?php }?>  
<?php if($thepage!=$totalpage&&$totalpage>0){?>
   <a href="<?=$url?>?page=<?=$thepage+1?>&check=<?=$check?>">下一页</a>&nbsp;<a href="<?=$url?>?page=<?=$totalpage?>&check=<?=$check?>">最后一页</a>&nbsp;
<?php }?>   
   【共<font color="red"><?=$totalrecord?></font>条记录】【每页<font color="red"><?=$maxpage?></font>条记录】【共<font color="red"><?=$totalpage?></font>页】<input type="text" name="page" size="3" onKeyUp="IsDigit(this);">&nbsp;<input type="submit" value="GO"></td></form>
</tr>
  </table>
</center>
</BODY>
</HTML>
<script language="javascript">
function IsDigit(obj) 
{ 
if(obj.value.replace(/[\d+]/ig,"").length>0) { 
  alert('请输入数字'); 
  document.getElementById(obj).value =""; 
} 
}

function del_friendlink(delid){
	if(confirm("你确定要删除该友情链接？")){
		location.href="friend.php?delid="+delid+"&check=<?=$check?>&page=<?=$thepage?>";
	}
}



</script>
